<?php
/**
 * Created by PhpStorm.
 * User: Hanson
 * Date: 2016/11/5
 * Time: 1:33
 */

namespace App\Repository;


use App\Model\Message;

class MessageRepository
{

    public $message;

    public function __construct(Message $message)
    {
        $this->message = $message;
    }

    /**
     * 留言总数
     *
     * @return int
     */
    public function getCount()
    {
        return $this->message->count();
    }

    public function getHeatMessage($limit = 5)
    {
        return $this->message->selectRaw('content, count(*) as count')->orderByRaw('count(*) desc')->groupBy('content')->limit($limit)->get();
    }

}